package com.xy.modular.owner.controller;

import com.xy.framework.base.controller.BaseController;
import com.xy.framework.mreturn.MReturnObject;
import com.xy.framework.pager.PageRequest;
import com.xy.modular.owner.model.Owner;
import com.xy.modular.owner.model.OwnerHouse;
import com.xy.modular.owner.service.IOwnerService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * Created by BCK on 2019/09/14.
 */
@Controller
@RequestMapping("/wx/owner/")
public class OwnerController extends BaseController {

	@Resource
	IOwnerService ownerService;

	@RequestMapping("/save")
	@ResponseBody
	public MReturnObject add(Owner Owner, OwnerHouse ownerHouse) {
		ownerService.save(Owner);
		return new MReturnObject(MReturnObject.SUCCESS);
	}

	@RequestMapping("/list")
	@ResponseBody
	public MReturnObject list(HttpServletRequest request) {
		PageRequest pageRequest = newPageRequest(request);
		return new MReturnObject(MReturnObject.SUCCESS, ownerService.findPageAll(pageRequest),
				ownerService.getCount(pageRequest));
	}
}
